import request from '@/axios'
import { CategoryParams, CategoryResponse } from './types'

export const getCategoryApi = (params: CategoryParams) => {
  return request.get<CategoryResponse>({ url: '/category/list', params })
}

export const deleteCategoryByIdApi = (ids: string[] | number[]) => {
  return request.delete({ url: '/category/delete', data: { ids } })
}

export const saveCategoryApi = (data: any) => {
  return request[data.id ? 'put' : 'post']({
    url: data.id ? '/category/edit' : '/category/add',
    data
  })
}

export const getCategoryByIdApi = (data: any) => {
  return request.get<CategoryResponse>({ url: '/category/detail?id=' + data })
}
